package cn.stazxr.frame;

import java.awt.*;

/**
 * Package: cn.stazxr.frame
 * Frame
 * @Author: stazxr
 * @Create: 2023/12/2
 * @Version: v1.0
 **/
public class FrameTest2 {
    public static void main(String[] args) {
        Frame frame = new Frame("我是标题");
        frame.setSize(500, 300);

        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();  //获取到屏幕尺寸
        int x = (int) ((screenSize.getWidth() - frame.getWidth()) / 2);   //居中位置就是：屏幕尺寸/2 - 窗口尺寸/2
        int y = (int) ((screenSize.getHeight() - frame.getHeight()) / 2);

        frame.setLocation(x, y);   //位置设置好了之后再展示出来
        frame.setCursor(new Cursor(Cursor.TEXT_CURSOR));  //设置鼠标样式
        frame.setVisible(true);
    }
}
